import framebuf
from machine import Pin, I2C
import ssd1306

from font import font16


i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)

def draw_chinese(oled, font, word, x, y):
    for ch in word:
        data = bytearray(font.get(ch, [0x00] * 32))
        fb = framebuf.FrameBuffer(data, 16, 16, framebuf.MONO_HLSB)
        oled.framebuf.blit(fb, x, y)  # 使用 oled.framebuf 的 blit
        x += 16

# 显示测试
oled.fill(0)
draw_chinese(oled, font16, '皮氪智能巡查系统', 0, 20)
oled.show()
